# //////////////////////////////////////////////////////////////////////////////
# //
# // Copyright © 1998-2024 Glodon Company Limited.
# //
# // Licensed under the MIT License
# //
# // Permission is hereby granted, free of charge, to any person obtaining a
# // copy of this software and associated documentation files (the “Software”),
# // to deal in the Software without restriction, including without limitation
# // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# // sell copies of the Software, and to permit persons to whom the Software is
# // furnished to do so, subject to the following conditions:
# //
# // The above copyright notice and this permission notice shall be included in
# // all copies or substantial portions of the Software.
# //
# // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# //
# //////////////////////////////////////////////////////////////////////////////


cmake_minimum_required(VERSION 3.11)
project(ExprEngine)

set(CMAKE_CONFIGURATION_TYPES "Debug;Release") 
set(CMAKE_CXX_FLAGS "/DWIN64 /D_WINDOWS /D_USRDLL /Zi /nologo /W3 /WX /MP  /EHsc -DUNICODE -D_UNICODE -D_CRT_SECURE_NO_WARNINGS /wd4250 /wd4251") 
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /MD /DNDEBUG") 
set(CMAKE_CXX_FLAGS_DEBUG "/Od /MDd /D_DEBUG") 
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /INCREMENTAL") 
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEBUG ") 

# COMPONENTEDITOR_SDK
if(DEFINED ENV{COMPONENTEDITOR_SDK_DIR})
    set(COMPONENTEDITOR_SDK $ENV{COMPONENTEDITOR_SDK_DIR} CACHE PATH  "Directory of ComponentEditor_SDK")
else ()
    set(COMPONENTEDITOR_SDK "" CACHE PATH  "Directory of ComponentEditor_SDK")
endif()

if(COMPONENTEDITOR_SDK STREQUAL "")
message("COMPONENTEDITOR_SDK NOTFOUND")
else()
message("COMPONENTEDITOR_SDK  ---- " ${COMPONENTEDITOR_SDK})
endif()

set(TARGET_NAME  ExprEngine) 

add_definitions(-DEXPRENGINE_EXPORTS) 
 
# Find includes in corresponding build directories 
set(CMAKE_INCLUDE_CURRENT_DIR ON) 


file(GLOB RootFiles source/*.cpp source/*.h source/*.rc source/*.ico source/*.json) 
source_group("" FILES ${RootFiles}) 
 
file(GLOB publicFiles ${CMAKE_CURRENT_SOURCE_DIR}/source/public/*.*) 
source_group("public" FILES ${publicFiles}) 
 
set(SOURCE_FILES ${RootFiles} ${publicFiles}) 
 
add_library(${TARGET_NAME} SHARED ${SOURCE_FILES}) 
 
target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/source/public ${COMPONENTEDITOR_SDK}/include)

target_link_directories(${TARGET_NAME} PRIVATE ${COMPONENTEDITOR_SDK}/lib)

target_link_libraries(${TARGET_NAME} 
GcmpDevService.lib
)
